package com.example.shopping.utils;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.http.app.ResponseParser;
import org.xutils.x;

import java.util.Map;

//联网
public class BaseFragment extends Fragment implements Callback.CommonCallback<String> {

    public  void  connectNetwork(String url){
        RequestParams params=new RequestParams(url);
        x.http().get(params,this);
    }
    public void  postNetwork(String url, Map<String,String>map){
        RequestParams params=new RequestParams(url);
        params.setAsJsonContent(true);
        params.setBodyContentType("application/json;charset=UTF_8");
        for (Map.Entry<String,String>entry:map.entrySet()) {
            String key=entry.getKey();
            String value=entry.getValue();
            params.addParameter(key,value);
        }
        x.http().post(params,this);
    }
    @Override
    public void onSuccess(String result) {

    }

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {

    }

    @Override
    public void onCancelled(CancelledException cex) {

    }

    @Override
    public void onFinished() {

    }
}
